package mr.ali.video.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import mr.ali.video.web.model.Actor;
import mr.ali.video.web.mapper.ActorMapper;
import mr.ali.video.web.service.IActorService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Mr-ali
 * @since 2024-09-08
 */
@Service
public class ActorServiceImpl extends ServiceImpl<ActorMapper, Actor> implements IActorService {

   @Resource
   private ActorMapper actorMapper;
   @Override
   public List<Actor> getActorList() {
      QueryWrapper queryWrapper = new QueryWrapper();
      queryWrapper.orderByDesc("id");
      List<Actor> getActorList = actorMapper.selectList(queryWrapper);
      return getActorList;
   }


   @Override
   public Actor getById(Integer id) {
      return actorMapper.selectById(id);
   }
   @Override
   public Actor getActorListByText(String text) {
      QueryWrapper<Actor> queryWrapper = new QueryWrapper<>();
      queryWrapper.like("name",text);
      List<Actor> actor = actorMapper.selectList(queryWrapper);;
      return actor.get(0);
   }


   @Override
   public Integer updateByAll(Actor video) {
      Integer rows =actorMapper.updateVideo(video);
      return rows;
   }

   @Override
   public Integer insertVideo(Actor video) {
      Integer rows = actorMapper.insert(video);
      return rows;
   }

   @Override
   public Integer deleteById(Integer id) {
      return actorMapper.deleteById(id);
   }

}
